package com.clothes;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.clothes.act.ASearch;
import com.clothes.act.BSearch;
import com.clothes.act.BaseActivity;
import com.clothes.act.CSearch;
import com.clothes.act.GetProduct;
import com.clothes.act.SlideRegister;
import com.clothes.act.SubmitProduct;
import com.clothes.act.WorkerMsg;
import com.clothes.app.ClothesApp;
import com.clothes.views.SearchDialog;

import butterknife.Bind;
import butterknife.OnClick;

public class MainActivity extends BaseActivity {

    @Bind(R.id.ll_worker)
    LinearLayout llWorker;
    @Bind(R.id.ll_pro)
    LinearLayout llPro;
    @Bind(R.id.ll_table)
    LinearLayout llTable;
    @Bind(R.id.ll_get_pro)
    LinearLayout llGetPro;
    @Bind(R.id.ll_sub_pro)
    LinearLayout llSubPro;
    @Bind(R.id.tv_title)
    TextView mTvTitle;
    @Bind(R.id.iv_back)
    ImageView mImageView;

    private SearchDialog searchDialog;

    @Override
    public void initView() {
        setContentView(R.layout.activity_main);
        searchDialog = new SearchDialog(this);
    }

    @Override
    public void initData() {
        String type = ClothesApp.getInstance().getWorkerInfo(this).getType();
//        if (!type.equals("1")) {
//            llWorker.setVisibility(View.INVISIBLE);
//            llPro.setVisibility(View.INVISIBLE);
//            llGetPro.setVisibility(View.INVISIBLE);
//            llSubPro.setVisibility(View.INVISIBLE);
//        }
        mTvTitle.setText("功能区");
        mImageView.setVisibility(View.INVISIBLE);
        searchDialog.setGoListener(new SearchDialog.GoListener() {
            @Override
            public void one() {
                goToActivity(ASearch.class, new Intent());
            }

            @Override
            public void two() {
                goToActivity(BSearch.class, new Intent());
            }

            @Override
            public void three() {
                goToActivity(CSearch.class, new Intent());
            }
        });
    }

    @OnClick({R.id.ll_worker, R.id.ll_pro, R.id.ll_table, R.id.ll_get_pro, R.id.ll_sub_pro})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_worker:
                goToActivity(WorkerMsg.class, new Intent());
                break;
            case R.id.ll_pro:
                goToActivity(SlideRegister.class, new Intent());
                break;
            case R.id.ll_table:
                searchDialog.show();
                break;
            case R.id.ll_get_pro:
                goToActivity(GetProduct.class, new Intent());
                break;
            case R.id.ll_sub_pro:
                goToActivity(SubmitProduct.class, new Intent());
                break;
        }
    }

}
